package com.dailyblue.project.smbms.alibaba.logistics.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.dailyblue.project.smbms.alibaba.commons.bean.Address;
import com.dailyblue.project.smbms.alibaba.commons.util.JsonResult;
import com.dailyblue.project.smbms.alibaba.logistics.feign.LogisticsFeign;
import com.dailyblue.project.smbms.alibaba.logistics.mapper.LogisticsMapper;
import com.dailyblue.project.smbms.alibaba.logistics.service.LogisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
@Slf4j
public class LogisticsServiceImpl implements LogisticsService {
    @Resource
    private LogisticsFeign feign;
    @Resource
    private LogisticsMapper mapper;

    @Override
    public void saveLogistics(String orderId, String aid) {
        Address result = feign.find(aid);
        Map<String, String> map = new HashMap<>();
        log.info("orderId:{},map:{}",orderId,result);
        log.info("address:{}",result);
        map.put("orderId", orderId);
        map.put("address", result.getAddressDesc());
        map.put("phone", result.getTel());
        map.put("consignee", result.getContact());
        mapper.saveLogistics(map);
    }
}
